// Author: Ivan Kazmenko (gassa@mail.ru)
module solution;
import std.algorithm;
import std.math;
import std.stdio;

struct Point
{
	int x;
	int y;
}

int vp () (const auto ref Point a,
    const auto ref Point b, const auto ref Point c)
{
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

real dist () (const auto ref Point a, const auto ref Point b)
{
	return sqrt ((a.x - b.x) ^^ 2 + 0.0L + (a.y - b.y) ^^ 2);
}

void main ()
{
	int tests;
	readf (" %s", &tests);
	foreach (test; 0..tests)
	{
		Point a, b, c, p, q;
		readf (" %s %s", &a.x, &a.y);
		readf (" %s %s", &b.x, &b.y);
		readf (" %s %s", &c.x, &c.y);
		readf (" %s %s", &p.x, &p.y);
		readf (" %s %s", &q.x, &q.y);
		real area = abs (vp (a, b, c));
		real base = max (dist (a, b), dist (b, c), dist (c, a));
		real gate = dist (p, q);
		writeln ((area / base <= gate) ? "YES" : "NO");
	}
}
